// 当前页面激活时Table数据更新（在table上加ref = "tableEl"，记录滚动条位置）
export default {
  data () {
    return {
      scrollTop: 0 // 记录tableEl滚动条高度
    }
  },
  async activated () {
    await this.getTableData()
    if (this.$refs.tableEl) {
      this.$refs.tableEl.$el.querySelector('.el-table__body-wrapper').scrollTop = this.scrollTop
      this.$nextTick(() => {
        this.$refs.tableEl.doLayout()
      })
    }
  },
  deactivated () {
    if (this.$refs.tableEl) {
      this.scrollTop = this.$refs.tableEl.$el.querySelector('.el-table__body-wrapper').scrollTop
    }
  }
}
